package com.bootssm.service.impl;

import com.bootssm.dao.UserMapper;
import com.bootssm.entity.User;
import com.bootssm.entity.UserLogin;
import com.bootssm.entity.UserVO;
import com.bootssm.service.UserService;
import com.bootssm.utils.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className: UserServiceImpl
 * @description: TODO 类描述
 * @author: Mr.Song
 * @date: 2024/01/09 16:10
 **/

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;
    @Autowired
    IdWorker idWorker;


    @Override
    public List<User> loninByUsernameAndPassword(UserLogin userLogin) {
        return userMapper.loninByUsernameAndPassword(userLogin);
    }


    @Override
    public List<User> findAllUser(UserVO userVO) {
        return userMapper.findAllUser(userVO);
    }


    @Override
    public User findUserByid(String userid) {
        return userMapper.findUserByid(userid);
    }

    @Override
    public void addUser(User user) {
        user.setUserid(idWorker.nextId()+"");
        userMapper.addUser(user);
    }


    @Override
    public void updateUser(User user) {
        userMapper.updateUser(user);
    }


    @Override
    public void deleteUserById(String userid) {
        userMapper.deleteUserById(userid);
    }

    @Override
    public Integer getCount(UserVO userVO) {
        return userMapper.getCount(userVO);
    }
}
